package com.yuneec.droneservice.command;

import com.yuneec.droneservice.request.IResponse;
import com.yuneec.droneservice.utils.ByteUtils;

/**
 * Created by gjw on 2017/3/27.
 */

public class SetChannelFormula extends BaseCommand {

    public SetChannelFormula(int index, int[] formula) {
        super(MAV_RC_COMMAND.MAV_RC_CMD_SET_CH_CURVE);
        data = new byte[1 + 2 * formula.length];
        data[0] = (byte) index;
        for (int i = 0; i < formula.length; i++) {
            ByteUtils.uShortToByteArray(data, 1 + 2 * i, formula[i], IS_BIGENDIAN);
        }
    }


    @Override
    public IResponse toResponse(byte[] data, int off, int len) {
        int code = data[off + 1] & 0xff;
        return new IResponse(ids(), code);
    }
}
